<template>
  <div id="wangeditor">
    <div ref="editorElem" style="text-align:left;"></div>
  </div>
</template>

<script>
import E from "wangeditor";
export default {
  name: "Editor",
  props:['editorContent'],
  data() {
    return {
      editor: null,
    };
  },
  mounted(){
    this.editor = new E(this.$refs.editorElem);
    this.editor.config.focus = false
    // 编辑器的失焦事件，每次改变会获取其html内容
    this.editor.config.onchange = (newHtml) => {
        this.$emit('getContent',newHtml)
    }
    this.editor.config.excludeMenus = [
        'link', // 插入链接
        'quote', // 引用
        'image', // 插入图片
        'video',
        'code',
        'todo',
        'emoticon'
    ]
    this.editor.create(); // 创建富文本实例
    this.editor.txt.html(this.editorContent)
  },
  methods:{
    clear(){
      this.editor.txt.clear()
    }
  }
}
</script>

<style>

</style>